<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <label for="keywords">keywords</label>
    <input type="text" id="keywords">
    <!-- autofocus-->
    <script>
        const input = document.querySelector('#keywords');
        // input.addEventListener('focus', function(event) {
        //     console.log(this);
        // });
        // input.addEventListener('change', function(event) {// change 输入框输入，失去焦点后触发
        //     console.log(this.value);
        // });
        input.addEventListener('keyup', function(event) { // keyup 键盘触发事件  keydown
            console.log(this.value);
            if (event.keyCode == 13) {
                console.log('提交表单');
            }
        });
        // input.addEventListener('input', function(event) {
        //     console.log(this.value);
        // });
        // input.focus();
    </script>
</body>

</html>